package com.heima.minio.MinioTest;


import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import org.junit.Test;

import java.io.FileInputStream;

public class MinIOTest {
    /**
     * 上传html文件
     * @param
     * @throws Exception
     */
    @Test
    public void test() throws Exception{

        //读取本地文件
        FileInputStream fileInputStream = new FileInputStream("E:\\IT HM\\heima 57\\Projects\\3project - FBS-WFW\\黑马头条\\day02-app端文章查看，静态化freemarker,分布式文件系统minIO\\资料\\文章详情-模板文件\\plugins\\css\\index.css");

        //创建minio客户端
        MinioClient client = MinioClient.builder()
                .credentials("minioadmin","minioadmin")//minio登录凭证
                .endpoint("http://124.220.92.69:9000") //minio链接地址
                .build();

        //上传
        PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                .object("plugins/css/index.css") //文件名称
                .bucket("minio57") //桶名称
                .contentType("text/css") //文件类型
                .stream(fileInputStream,fileInputStream.available(),-1).build();
        client.putObject(putObjectArgs);

        //访问地址
        System.out.println("http://192.168.200.130:9000/leadnews/list.html");
    }
}